package com.jsnkj.basic.activity

import android.os.Bundle
import android.view.View
import com.jsnkj.basic.R
import com.jsnkj.basic.databinding.ActivityMyPurseBinding
import com.jsnkj.basic.mvvm.BaseKtActivity
import com.jsnkj.basic.util.MediaUtil


//我的钱包
class MyPurseActivity : BaseKtActivity<ActivityMyPurseBinding, MyPurseViewModel>(),
    View.OnClickListener {
    override val layoutId: Int
        get() = R.layout.activity_my_purse

    override fun initView(savedInstanceState: Bundle?) {
        mVDB.clickListener = this
        MediaUtil.heartBeat(mVDB.imgLjtx)

//        AdvertisementManager.loadBanner(
//            this@MyPurseActivity,
//            SharePreferencesUtil.getInstance().getInt("app_screenWidth", 350) - 40,
//            mVDB.flContainer,
//            object : TbManager.BannerLoadListener {
//                override fun onFail(s: String) {
//                    BurialPointUtil.bannerAdEvent("fail")
//                    LogUtils.e("banner广告 加载失败：$s")
//                    mVDB.flContainer.visibility = View.INVISIBLE
//                }
//
//                override fun onDismiss() {
//                    mVDB.flContainer.visibility = View.INVISIBLE
//                }
//
//                override fun onClicked() = Unit
//                override fun onExposure(position: Position) {
//                    BurialPointUtil.bannerAdEvent("show")
//                    RewardsUtil.addGoldNumber(position.ecpm, RewardsConfig.adBanner)
//                }
//            })

        mVM.postPopularizePurse()

    }

    override fun bindEvent() {
        super.bindEvent()

        mVM.postHttpResult.observe(this) { entity ->

            //txt_my_wallet
            mVDB.txtMyWallet.text = "￥${entity.getWithdrawable()}"

            mVDB.txtNumber.text = "${entity.getIncomes()?.yesterday}"
            mVDB.txtMakeMoney.text = "${entity.getIncomes()?.today}"
            mVDB.txtWithdrawalMoney.text = "${entity.getIncomes()?.total}"
        }

    }

    override fun onClick(view: View) {
        when (view.id) {
            R.id.image_return -> {
                onBackPressed()
            }

            R.id.img_withdrawal_record -> {
                startActivity(CashRecordActivity::class.java)
            }

            R.id.img_ljtx -> {
                startActivity(WithdrawActivity::class.java)
            }
        }
    }


}